POV-Ray : Newsgroups : povray.advanced-users : Allowing reserved keywords to be used as identifier names? : Re: Allowing reserved keywords to be used as identifier names? Server Time
28 Jul 2024 18:16:40 EDT (-0400)
  Re: Allowing reserved keywords to be used as identifier names?  
From: Warp
Date: 31 May 2004 07:58:48
Message: <40bb1df8@news.povray.org>
Leonardo <lmf### [at] megaistutlpt> wrote:
> #declare fresnel = 0;
> #declare MyFinish = finish { reflection { 0.5 metallic fresnel } };

> The parser wont know if it's supposed to be:
> #declare MyFinish = finish { reflection { 0.5 metallic 0 } };
> or
> #declare MyFinish = finish { reflection { 0.5 metallic on fresnel on } };

  The parser could use intelligent heuristics to decide which interpretation
is correct.
  The simplest heuristic would be: "This is the name of a keyword. If
I use it as a keyword in this place, will it cause a syntax error? If
yes, use it as a keyword, else use it as an identifier name." That is,
the name of a keyword is always used as a keyword if possible (ie. it
doesn't cause an error), and only if it won't work as a keyword it will
be tested as an identifier.

  Another possibility is to issue an error message about the ambiguous use
of the name in that place.

> If I'm not mistaken, the current parser of POVRay SDL does not allow
> lookaheads.
> This would imply the total re-writing of the grammar to migrate to a parser
> that supports lookahead.

  As I said, I didn't suggest this should be done. I was just thinking
aloud... :)

> I think a good keyword name never conflicts with good variable names.

  Sometimes this is not possible. For example "size" is a good variable
name and a good keyword name. The same applies to many other examples,
such as "radius", "location", "angle", etc.

> Maybe an alternative solution is to use some operator to refer to variables,
> as $ in PHP.

  This would make writing SDL more complicated. I'm not really sure I like
that.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.